<%@ page language="java" import="java.util.*"
	import="com.sellerSystem.vo.*" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>欢迎！</title>
</head>

<style type="text/css">
body {
	text-align: center
}

.div {
	margin: 0 auto;
	width: 600px;
	height: 100px;
}

.unchanged {
	border: 0;
}

#welcome {
	text-align: right;
}

#table {
	text-align: center;
	width: 100%;
	font-size: 20px;
}

#index {
	text-align: right;
}
</style>


<script src="js/jquery-1.12.0.min.js" type=text/javascript></script>


</head>

<body onResize="Resize()">
	<p id="welcome">
		<i>欢迎<b>${seller.sellerName}</b>来到您的个人商铺！
		</i>
	</p>
	<p id="index">
		<a href="loginSuc.jsp">首页</a>&nbsp;&nbsp;<a href="index.html">退出系统</a>&nbsp;
	</p>
	<!-- <form action="modifycommodity" method="post">  -->



	<table id="table"></table>
	<!-- </form> -->
</body>
<script>
	var I = null;

	var thisURL = document.URL;
	var showval = thisURL.split("=")[1];
	//进入个人店铺页面显示所有个人商品
	$(document)
			.ready(
					function() {

						$
								.ajax(
										"loginSuc",
										{
											type : "POST",
											dataType : 'text',
											success : function(data) {

												//alert(data);
												var jsonObj = eval("(" + data
														+ ")");

												$("#table")
														.html(
																"<tr><td>商品序号</td><td>商品名称</td><td >商品图片</td><td>商品种类</td><td>商品单价</td><td>商品库存量</td><td>商品描述</td><td>质量保障</td></tr>")
												$
														.each(
																jsonObj,
																function(i,
																		item) {
																	if (item.commodityId == showval) {
																		I = item;
																		$(
																				"#table")
																				.append(
																						"<tr><td>"
																								+ item.commodityId
																								+ "</td><td>"
																								+ "<input id='name' type='text' value='"
																								+ item.commodityName
																								+ "'"
																								+ "</td><td>"
																								+ "<img id='pic' src="+item.commodityPic+">"
																								+ "</td><td>"
																								+ item.commodityKinds
																								+ "</td><td>"
																								+ "<input id='pri' type='text' value='"
																								+ item.commodityPrice
																								+ "'"
																								+ "</td><td>"
																								+ "<input id='num' type='text' value='"
																								+ item.commodityNumber
																								+ "'"
																								+ "</td><td>"
																								+ "<input id='des' type='text' value='"
																								+ item.commodityDescribe
																								+ "'"
																								+ "</td><td>"
																								+ "<input id='gua' type='text' value='"
																								+ item.commodityGuaranty
																								+ "'"
																								+ "</td>"
																								+ "<td><button onclick='f()'>确定修改</button></td>"
																								+ "</tr>"

																				)

																	}
																	//alert(item.sellerId + ","  + item.sellerName);

																});
											}
										});
					});

	function f() {

		var id = I.commodityId;
		var name = document.getElementById("name").value;
		var pic = I.commodityPic;
		var kin = I.commodityKinds;
		var pri = document.getElementById("pri").value;
		var num = document.getElementById("num").value;
		var des = document.getElementById("des").value;
		var gua = document.getElementById("gua").value;
		var commodity = {
			"commodityId" : id,
			"commodityName" : name,
			"commodityPic" : pic,
			"commodityKinds" : kin,
			"commodityPrice" : pri,
			"commodityNumber" : num,
			"commodityDescribe" : des,
			"commodityGuaranty" : gua,
		}
		$.ajax("modifycommodity", {
			data : commodity,
			type : "POST",
			success : function() {
				//alert("ok");
				alert("修改完成");
				window.location.href = "commodity.jsp?data=" + I.commodityId + "";
			}

		});
	}

	// 	$("#btn").on("click",function(){
	// 		alert("sda");

	// 		$.ajax("modifyCommodity",{
	// 				data : item,
	// 				type : "POST",
	// 				success : function(){
	// 					alert("ok");
	// 					alert(item.commodityPrice);
	// 				}

	// 		});

	// });
</script>

















<script language="JavaScript" type="text/javascript">
	$(function() {
		var winWidth, winHeight;
		Resize = function() {
			winWidth = $(window).width(), winHeight = $(window).height();
		}
	});
</script>

</html>